package com.example.administrator.yuejian_15.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.example.administrator.yuejian_15.activity.JlbInfoActivity;
import com.example.administrator.yuejian_15.bean.JlbBean;
import com.example.administrator.yuejian_15.service.Service;
import com.squareup.picasso.Picasso;

import java.util.List;

public class JlbAdapter extends BaseAdapter<JlbBean> {

    public JlbAdapter(Context context, List<JlbBean> items, int layoutResourse) {
        super(context, items, layoutResourse);
    }

//    @Override
//    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//        View itemView = LayoutInflater.from(context).inflate(layoutResourse,parent,false);
//        ItemViewHolder itemViewHolder = new ItemViewHolder(itemView);
//        return itemViewHolder;
//    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ItemViewHolder itemViewHolder=(ItemViewHolder) holder;
        JlbBean jlbBean=items.get(position);

        final String jlbname = jlbBean.getJlbname();
        final String jlbid = jlbBean.getJlbid();

        final String jlbintro = jlbBean.getJlbintro();
        final String jlbaddress =jlbBean.getJlbaddress();
        final String jlbphoen = jlbBean.getJlbphone();
        final String jlbtime = jlbBean.getJlbtime();
        final String jlbpic= Service.BASE_URL+"yuejian/public/static/jlbimg/jlbinfoimg/"+jlbBean.getJlbpic();
        Picasso.with(context).load(jlbpic).into(itemViewHolder.img1);

        itemViewHolder.tv1.setText("俱乐部:"+jlbname);
        itemViewHolder.tv2.setText("地址:"+jlbaddress);
        itemViewHolder.tv3.setText("开放时间:"+jlbtime);

        itemViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(context, JlbInfoActivity.class);
                intent.putExtra("jlbid",jlbid);
                context.startActivity(intent);
            }
        });

    }
}
